跳到主要内容

格式化 string 小技巧

printf '%b\n' 'if len(array) <= 1 {\n\t\treturn\n\t}\n\t'
echo 'if len(array) <= 1 {\n\t\treturn\n\t}\n\t'

if len(array) <= 1 {
return
}
%
%b expands all backslash escape sequences not just \t or \n. For example it will also expand \f (form feed) or \r (carriage return). Check help printf or help echo for more details.